/**
 * @Description:1秒内防止多次点击
 * @author TangYong
 * @date 2022/12/17
 */
import {Toast} from './Toast';


let isCalled = false
let timer
export const preventDoubleClick = (functionTobeCalled, interval = 1000) => {
    if (isCalled==true){
        Toast.showWarning(interval/1000+'秒内只允许操作一次！请稍后再试！')
    }
    if (!isCalled) {
        isCalled = true
        clearTimeout(timer)
        timer = setTimeout(() => {
            isCalled = false
        }, interval)
        return functionTobeCalled()
    }
}

